function objectFactory(){

  const constructor = Array.prototype.shift.call(arguments)

  if(typeof constructor !=='function'){
    return
  }

  let newObject = {};
  let result = null;

  //newObject = Object.create(constructor.prototype)
  newObject.__proto__ = constructor.constructor

  result = constructor.apply(newObject,arguments)
  let flag = result && (typeof result==="object"|| typeof result==="function")
  
  return flag?result:newObject;


}

function myConstructor(){
  this.data = 'my constructor'
}

myConstructor.prototype.getData = function(){
  
  return this.data
}

const instance1 = objectFactory(myConstructor)

console.log(instance1)